|
1
|
|
|
'use strict'; |
|
2
|
|
|
|
|
3
|
|
|
angular.module('game').component('supernova', { |
|
4
|
|
|
templateUrl: 'views/supernova.html', |
|
5
|
|
|
controller: ['state', 'format', 'visibility', 'upgrade', 'data', 'util', supernova], |
|
6
|
|
|
controllerAs: 'ct' |
|
7
|
|
|
}); |
|
8
|
|
|
|
|
9
|
|
|
function supernova(state, format, visibility, upgrade, data, util) { |
|
10
|
|
|
let ct = this; |
|
11
|
|
|
ct.state = state; |
|
12
|
|
|
ct.visibility = visibility; |
|
13
|
|
|
ct.data = data; |
|
14
|
|
|
ct.util = util; |
|
15
|
|
|
ct.format = format; |
|
16
|
|
|
ct.infuse = {}; |
|
17
|
|
|
|
|
18
|
|
|
ct.exoticProduction = function() { |
|
19
|
|
|
let production = {}; |
|
20
|
|
|
let exotic = data.elements[state.currentElement].exotic; |
|
21
|
|
|
production[exotic] = 0; |
|
22
|
|
|
for (let resource of data.elements[state.currentElement].includes) { |
|
23
|
|
|
if (!state.player.resources[resource].unlocked) { |
|
24
|
|
|
continue; |
|
25
|
|
|
} |
|
26
|
|
|
if (data.resources[resource].type.indexOf('molecule') !== -1) { |
|
27
|
|
|
let multiplier = 0; |
|
28
|
|
|
for (let key in data.resources[resource].elements) { |
|
29
|
|
|
let number = data.resources[resource].elements[key]; |
|
30
|
|
|
multiplier += number; |
|
31
|
|
|
} |
|
32
|
|
|
for (let element in data.resources[resource].elements) { |
|
33
|
|
|
let newExotic = data.elements[element].exotic; |
|
34
|
|
|
production[newExotic] = production[newExotic] || 0; |
|
35
|
|
|
production[newExotic] += Math.floor(Math.max(0, Math.log(state.player.resources[resource].number))) * multiplier; |
|
36
|
|
|
} |
|
37
|
|
|
}else{ |
|
38
|
|
|
production[exotic] += Math.floor(Math.max(0, Math.log(state.player.resources[resource].number))); |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
for (let key in production) { |
|
42
|
|
|
// we adjust the production to start at 1e6 resources |
|
43
|
|
|
if (production[key] >= 13) { |
|
44
|
|
|
production[key] -= 13; |
|
45
|
|
|
} else { |
|
46
|
|
|
production[key] = 0; |
|
47
|
|
|
} |
|
48
|
|
|
// we adjust the infusion |
|
49
|
|
|
production[key] += Math.floor(production[key]*ct.totalInfuseBoost()); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
return production; |
|
53
|
|
|
}; |
|
54
|
|
|
|
|
55
|
|
|
ct.exoticPrestige = function() { |
|
56
|
|
|
let resources = state.player.resources; |
|
57
|
|
|
let production = ct.exoticProduction(); |
|
58
|
|
|
|
|
59
|
|
|
for (let key in production) { |
|
60
|
|
|
resources[key].number += production[key]; |
|
61
|
|
|
resources[key].unlocked = true; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
upgrade.resetElement(state.player, state.currentElement); |
|
65
|
|
|
}; |
|
66
|
|
|
|
|
67
|
|
|
ct.buyExoticUpgrade = function(name, element) { |
|
68
|
|
|
let upgrades = state.player.elements[element].exotic_upgrades; |
|
69
|
|
|
let price = data.exotic_upgrades[name].price; |
|
70
|
|
|
let currency = data.elements[element].exotic; |
|
71
|
|
|
upgrade.buyUpgrade(state.player, |
|
72
|
|
|
upgrades, |
|
73
|
|
|
name, |
|
74
|
|
|
price, |
|
75
|
|
|
currency); |
|
76
|
|
|
}; |
|
77
|
|
|
|
|
78
|
|
|
ct.setPercentage = function(resource, percentage) { |
|
79
|
|
|
ct.infuse[resource] = Math.floor(state.player.resources[resource].number*(percentage/100)); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
ct.fixNumber = function(resource) { |
|
83
|
|
|
ct.infuse[resource] = Math.max(0, Math.min(state.player.resources[resource].number, ct.infuse[resource])); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
ct.isValidInfusion = function() { |
|
87
|
|
|
let valid = true; |
|
88
|
|
|
for(let resource in ct.infuse){ |
|
89
|
|
|
console.log(resource+" "+ct.infuse[resource]+" "+Number.isFinite(ct.infuse[resource])); |
|
|
|
|
|
|
90
|
|
|
valid = valid && Number.isFinite(ct.infuse[resource]); |
|
91
|
|
|
} |
|
92
|
|
|
return valid; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
ct.totalInfuseBoost = function() { |
|
96
|
|
|
let total = 1; |
|
97
|
|
|
for(let resource in ct.infuse){ |
|
98
|
|
|
let number = Math.min(ct.infuse[resource], state.player.resources[resource].number); |
|
99
|
|
|
total *= 1+number*ct.data.constants.INFUSE_POWER; |
|
100
|
|
|
} |
|
101
|
|
|
return total-1; |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|